<template>
  <div class="form">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item
        :label="item.label"
        :key="index"
        v-for="(item, index) in formLabel"
      >
        <!-- 输入框 -->
        <el-input
          v-model="form[item.key]"
          v-if="item.type === 'input'"
        ></el-input>
        <!-- 下拉框 -->
        <el-select
          v-model="form[item.key]"
          placeholder="请选择活动区域"
          v-if="item.type === 'select'"
        >
          <el-option
            :key="index"
            :label="subitem.value"
            v-for="(subitem, index) in item.options"
            :value="subitem.value"
          ></el-option>
        </el-select>
        <el-date-picker
          v-if="item.type === 'date-picker'"
          type="date"
          placeholder="选择日期"
          v-model="form[item.key]"
          style="width: 100%"
        ></el-date-picker>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      formLabel: [
        {
          label: "活动名称",
          key: "name",
          type: "input",
        },
        {
          label: "活动区域",
          key: "region",
          type: "select",
          options: [
            {
              label: "区域一",
              value: "shanghai",
            },
            {
              lable: "区域二",
              value: "beijing",
            },
          ],
        },
        {
          label: "活动时间",
          key: "date",
          type: "date-picker",
        },
      ],
    };
  },
  methods: {},
  created() {},
};
</script>
<style scoped></style>
